-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(playground): accumulate errors while parsing span attributes #4941
feat(playground): accumulate errors while parsing span attributes #4941
Conversation
import { PlaygroundSpan } from "./spanPlaygroundPageLoader"; | ||
|
||
/** | ||
* Checks if a string is a valid chat message role | ||
*/ | ||
export function isChatMessageRole(role: unknown): role is ChatMessageRole { | ||
return chatMessageRoles.includes(role as ChatMessageRole); | ||
return chatMessageRolesSchema.safeParse(role).success; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't have to use this but i wanted to add it to the shcmea for ChatMessages so figured would update here as well
* The role of a chat message with a LLM | ||
*/ | ||
export type ChatMessageRole = (typeof chatMessageRoles)[number]; | ||
export enum ChatMessageRole { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needed these actual values in a few places so switched to enum
import { PlaygroundInstanceProps } from "./types"; | ||
|
||
interface PlaygroundOutputProps extends PlaygroundInstanceProps {} | ||
|
||
export function PlaygroundOutputMessage({ message }: { message: ChatMessage }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we want to show this card in all cases but wanted it for span parsing, seems to be a common way to display
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't export.
What do you mean you wanted it for "span parsing" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah export was a mistake
also the parsing wording was a brain fart haha, wanted it for displaying output messages parsed from the original span** is what i meant to say
message={{ | ||
id: generateMessageId(), | ||
content: output, | ||
role: ChatMessageRole.ai, | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can update output messages to not need id, seems fine to keep for now
// expect(getChatRole("bot")).toEqual("ai"); | ||
// expect(getChatRole("system")).toEqual("system"); | ||
// expect(getChatRole("human:")).toEqual("user"); | ||
expect(getChatRole("bot")).toEqual("ai"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
@@ -28,6 +29,7 @@ export function PlaygroundInstance(props: PlaygroundInstanceProps) { | |||
return ( | |||
<PanelGroup direction={isSingleInstance ? "horizontal" : "vertical"}> | |||
<Panel defaultSize={50} order={1} css={panelContentCSS}> | |||
<PlaygroundInstanceErrors {...props} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we eventually put this in a banner as a single "warning". Can always refactor
<Flex direction="column" gap={"size-50"}> | ||
{parsingErrors.map((error, i) => { | ||
return ( | ||
<Alert | ||
variant="warning" | ||
dismissable | ||
key={error} | ||
onDismissClick={() => { | ||
updateInstance({ | ||
instanceId, | ||
patch: { | ||
parsingErrors: parsingErrors.filter((_, j) => i !== j), | ||
}, | ||
}); | ||
}} | ||
> | ||
{error} | ||
</Alert> | ||
); | ||
})} | ||
</Flex> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe one alert with a detail
element might be cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i like that, i can refactor
import { PlaygroundInstanceProps } from "./types"; | ||
|
||
interface PlaygroundOutputProps extends PlaygroundInstanceProps {} | ||
|
||
export function PlaygroundOutputMessage({ message }: { message: ChatMessage }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't export.
What do you mean you wanted it for "span parsing" ?
if (isChatMessages(instance.output)) { | ||
const messages = instance.output; | ||
|
||
return messages.map((message, index) => { | ||
return <PlaygroundOutputMessage key={index} message={message} />; | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh as in this was the original output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, displaying the original output but then also displaying new outputs in the same way
f918d83
to
691beb7
Compare
cf18e34
to
5990585
Compare
319d479
to
4efc271
Compare
4efc271
to
02e1d82
Compare
ee38d2e
to
6f79a05
Compare
) * feat(playground): accumulate errors while parsing span attributes * update tests to include message id's / tools * update output for runs * update comments / test names * move parsing errors into span playground banners * cleanup spanplaygroundpage * add function to verify zod schema matches type
resolves #4922
Errors
Output